#ifndef OMG_DDS_BUILTIN_TYPES_HPP_
#define OMG_DDS_BUILTIN_TYPES_HPP_

/* Copyright (c) 2009-2010, Real-Time Innovations, Inc.
 * Copyright (c) 2010, Object Management Group, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 * - Neither the names of the above copyright holders nor the names of their
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL A COPYRIGHT HOLDER OR CONTRIBUTOR BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR PROFITS, OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


#ifdef OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT


// --- String: ---------------------------------------------------------------

class dds::type::builtin::StringDataWriter :
    public dds::pub::DataWriter<std::string>
{
    OMG_DDS_REFERENCE_TYPE(StringDataWriter)
};


class dds::type::builtin::StringDataReader :
    public dds::sub::DataReader<std::string>
{
    OMG_DDS_REFERENCE_TYPE(StringDataReader)
};


// --- Keyed string: ---------------------------------------------------------

class dds::type::builtin::KeyedStringDataWriter :
    public dds::pub::DataWriter<KeyedString>
{
    OMG_DDS_REFERENCE_TYPE(KeyedStringDataWriter)

public:
    using dds::pub::DataWriter<KeyedString>::register_instance;
    dds::core::InstanceHandle register_instance(const std::string& key);
    dds::core::InstanceHandle
    register_instance(const std::string& key,
                      const dds::core::Time& source_timestamp);

    using dds::pub::DataWriter<KeyedString>::unregister_instance;
    void unregister_instance(const std::string& key);
    void unregister_instance(const std::string& key,
                             const dds::core::Time& source_timestamp);

    using dds::pub::DataWriter<KeyedString>::write;
    void write(const std::string& key,
               const std::string& str);
    void write(const std::string& key,
               const std::string& str,
               const dds::core::InstanceHandle& handle);
    void write(const std::string& key,
               const std::string& str,
               const dds::core::InstanceHandle& handle,
               const dds::core::Time& source_timestamp);

    using dds::pub::DataWriter<KeyedString>::dispose;
    void dispose(const std::string& key);
    void dispose(const std::string& key,
                 const dds::core::Time& source_timestamp);

    using dds::pub::DataWriter<KeyedString>::get_key_value;
    const std::string get_key_value(const dds::core::InstanceHandle& handle);
    
    using dds::pub::DataWriter<KeyedString>::lookup_instance;
    const dds::core::InstanceHandle lookup_instance(const std::string& key);
};


class dds::type::builtin::KeyedStringDataReader :
    public dds::sub::DataReader<KeyedString>
{
    OMG_DDS_REFERENCE_TYPE(KeyedStringDataReader)
};


// --- Bytes: ----------------------------------------------------------------

class dds::type::builtin::BytesDataWriter :
    public dds::pub::DataWriter<dds::core::ByteSeq>
{
    OMG_DDS_REFERENCE_TYPE(BytesDataWriter)
    
public:
    using dds::pub::DataWriter<dds::core::ByteSeq>::write;
    template <typename RNDA_ITER>
    void write(RNDA_ITER begin,
               RNDA_ITER end);
    template <typename RNDA_ITER>
    void write(RNDA_ITER begin,
               RNDA_ITER end,
               const dds::core::InstanceHandle& handle);
    template <typename RNDA_ITER>
    void write(RNDA_ITER begin,
               RNDA_ITER end,
               const dds::core::InstanceHandle& handle,
               const dds::core::Time& source_timestamp);
};


class dds::type::builtin::BytesDataReader :
    public dds::sub::DataReader<dds::core::ByteSeq>
{
    OMG_DDS_REFERENCE_TYPE(BytesDataReader)
}; 


// --- Keyed bytes: ----------------------------------------------------------

class dds::type::builtin::KeyedBytesDataWriter :
    public dds::pub::DataWriter<KeyedBytes>
{
    OMG_DDS_REFERENCE_TYPE(KeyedBytesDataWriter)

public:
    using dds::pub::DataWriter<KeyedBytes>::register_instance;
    const dds::core::InstanceHandle register_instance(const std::string& key);
    const dds::core::InstanceHandle
    register_instance(const std::string& key,
                      const dds::core::Time& source_timestamp);

    using dds::pub::DataWriter<KeyedBytes>::unregister_instance;
    void unregister_instance(const std::string& key);
    void unregister_instance(const std::string& key,
                             const dds::core::Time& source_timestamp);

    using dds::pub::DataWriter<KeyedBytes>::write;
    template <typename RNDA_ITER>
    void write(const std::string& key,
               RNDA_ITER value_begin,
               RNDA_ITER value_end);
    template <typename RNDA_ITER>
    void write(const std::string& key,
               RNDA_ITER value_begin,
               RNDA_ITER value_end,
               const dds::core::InstanceHandle& handle);
    template <typename RNDA_ITER>
    void write(const std::string& key,
               RNDA_ITER value_begin,
               RNDA_ITER value_end,
               const dds::core::InstanceHandle& handle,
               const dds::core::Time& source_timestamp);

    using dds::pub::DataWriter<KeyedBytes>::dispose;
    void dispose(const std::string& key);
    void dispose(const std::string& key,
                 const dds::core::Time& source_timestamp);

    using dds::pub::DataWriter<KeyedBytes>::get_key_value;
    const std::string get_key_value(const dds::core::InstanceHandle& handle);

    using dds::pub::DataWriter<KeyedBytes>::lookup_instance;
    const dds::core::InstanceHandle lookup_instance(const std::string& key);
};


class dds::type::builtin::KeyedBytesDataReader :
    public dds::sub::DataReader<KeyedBytes>
{
    OMG_DDS_REFERENCE_TYPE(KeyedBytesDataReader)
};


#endif  // defined(OMG_DDS_EXTENSIBLE_AND_DYNAMIC_TOPIC_TYPE_SUPPORT)


#endif // !defined(OMG_DDS_BUILTIN_TYPES_HPP_)
